﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Web.Mvc;
using FazaDemo.WebSiteMvc.Controllers;
using Moq;
using FazaDemo.ViewModels;
using FazaDemoSolution.BL.Domain.AbstractCore;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FazaDemo.BL.AppFacade;
using FazaDemo.PL.Mapping;
using FazaDemo.ViewModels;
using FazaDemoSolution.BL.Domain.AbstractCore;

namespace FazaDemo.WebSiteMvc.Tests
{
    /// <summary>
    /// Summary description for SupplementalControllerTest
    /// </summary>
    [TestClass]
    public class SupplementalControllerTest
    {

        private const int Id = 2001;

        private ISuppInfoReceiver _infoReceiver;

        private IContainerElementMapper<InfoEntity, SuppleViewModel> _mapper;

        private IEnumerable<InfoEntity> _suppInfo;

        private IEnumerable<SuppleViewModel> _suppInfoModels;

        private string _suppTitle;

        private SupplementalController _controller;

        private Func<SupplementalController, ActionResult> _output;

        [TestInitialize]
        public void TestInit()
        {
            _infoReceiver = new SuppInfoReceiver();
            _mapper = new ContainerElementMapper<InfoEntity, SuppleViewModel>();
            _suppInfo = new List<InfoEntity>();
            _suppInfoModels = new List<SuppleViewModel>();
            _suppTitle = "";
            _output = OutputFunc;
        }

        [TestMethod]
        public void OutputBehaviorVerificationTest()
        {
            ////Arrange
            //var mockRep = new MockRepository(MockBehavior.Loose);
            //var infoReceiverMock = mockRep.Create<ISuppInfoReceiver>();
            //infoReceiverMock.Setup(r => r.GetSuppInfo(It.IsAny<int>())).Returns<int>(r => _suppInfo);
            ////infoReceiverMock.Setup(r => r.GetSuppTitle(It.IsAny<int>())).Returns<int>(r => _suppTitle);
            //var mapperMock = mockRep.Create<IContainerElementMapper<InfoEntity, SuppleViewModel>>();
            //mapperMock.Setup(m => m.MapFrom(It.IsAny<IEnumerable<InfoEntity>>()))
            //    .Returns<IEnumerable<InfoEntity>>(m => _suppInfoModels);
            //_controller = new SupplementalController(infoReceiverMock.Object, mapperMock.Object);
            ////Act
            //_output(_controller);
            ////Assert
            //mockRep.Verify();
        }

        [TestMethod]
        public void OutputTest()
        {
            ////Arrange
            //var infoReceiverDep = Mock.Of<ISuppInfoReceiver>(r => r.GetSuppInfo(It.IsAny<int>()) == _suppInfo 
            //    && r.GetSuppTitle(It.IsAny<int>()) == _suppTitle);
            //var mapperDep = Mock.Of<IContainerElementMapper<InfoEntity, SuppleViewModel>>
            //    (m => m.MapFrom(It.IsAny<IEnumerable<InfoEntity>>()) == _suppInfoModels);
            //_controller = new SupplementalController(infoReceiverDep, mapperDep);
            ////Act
            //var result =  _output(_controller) as ViewResult;
            ////Assert
            //Assert.IsNotNull(result);
            //Assert.AreEqual(result.Model.GetType(), typeof(SuppleOutputViewModel));
        }

        private ActionResult OutputFunc(SupplementalController controller)
        {
            return controller.Output(Id);
        }

    }
}
